package com.ghck.server.bkcontroller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.alibaba.fastjson.JSONObject;
import com.ghck.server.model.SmsVerification;
import com.ghck.server.model.query.SmsVerificationQuery;
import com.ghck.server.service.SmsVerificationService;
import com.ghck.shop.model.Page;
@Controller
@RequestMapping("/system/sms")
public class AdminSmsController {

	@Autowired
	private SmsVerificationService smsVerificationService;
	
	@RequestMapping(value="/list")
	public String main(HttpServletRequest request,
			@RequestParam(defaultValue = "1") Integer currentPage,
			@RequestParam(defaultValue = "10") Integer pageSize){
		SmsVerificationQuery query = new SmsVerificationQuery();
		if(currentPage > 0 ){
			query.setStart((currentPage-1)*pageSize);
			query.setLimit(pageSize);
		}
		Page<SmsVerification> page = new Page<SmsVerification>(currentPage);
		page.setPageSize(pageSize);
		page.setResultRows(smsVerificationService.findSmsVerificationByQuery(query));
		page.setTotalRow(smsVerificationService.countSmsVerificationByQuery(query));
		System.out.println("page:"+JSONObject.toJSONString(page));
		request.setAttribute("page", page);
		return "back/sms/list";
	}
}
